package fr.esiea.es_inf5042.persistance.dao.SQLiteDAO;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import fr.esiea.es_inf5042.business.Bargain;
import fr.esiea.es_inf5042.business.Comment;
import fr.esiea.es_inf5042.business.User;
import fr.esiea.es_inf5042.persistance.dao.AbstractDAOFactory;
import fr.esiea.es_inf5042.persistance.dao.DAO;

public class SQLiteDAOFactory extends AbstractDAOFactory {

	private static Context CONTEXT;
	private SQLiteDatabase database;
	
	public SQLiteDAOFactory(Context context) {
		
		SQLiteFactoryOpenHelper databaseHelper = null; 
		
		this.CONTEXT = context;						
		
		//context.deleteDatabase("SQLiteEmbeddedDataBase");
		
		databaseHelper = new SQLiteFactoryOpenHelper(context);
		database = databaseHelper.getDatabase();
	
	}

	@Override
	public DAO<User> getUserDAO()
	{
		return new SQLiteUserDAO(database);
	}
	
	@Override
	public DAO<Bargain> getBargainDAO() 
	{
		return new SQLiteBargainDAO(database);
	}
	
	@Override
	public DAO<Comment> getCommentDAO()
	{
		return new SQLiteCommentDAO(database);
	}	
	
	public static Context getContext() {
		return CONTEXT;
	}

	public SQLiteDatabase getDatabase() {
		return database;
	}
}
